<!--
 * @Author: HeAo
 * @Date: 2021-09-29 16:03:05
 * @LastEditTime: 2021-09-29 16:13:07
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \web2103-2105\web2105\3-1-ES6\day05\5-generator-ajax.html
 * 别乱动！
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>generator-ajax</title>
  <script src="./jquery.js"></script>
  <script>
    const baseUrl = 'http://47.94.46.113:8888'
    function getAjax() {
      return $.ajax({
        url: baseUrl + '/index/category/findAll',
        method: 'get',
        success(res) {
          iterator.next(res)
        },
        error(err) {

        }
      })
    }

    function* myGunFun() {
      let result = yield getAjax()

      console.log('状态二处理数据', result);
      yield '结束'
    }
    // generator函数执行结果，返回迭代器对象
    let iterator = myGunFun()
    iterator.next()
  </script>
</head>

<body>

</body>

</html>